package com.cxcy.swustlearner.controller;

import com.cxcy.swustlearner.pojo.College;
import com.cxcy.swustlearner.pojo.StaticUser;
import com.cxcy.swustlearner.service.CollegeService;
import common.ConstStatus;
import common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("college")
public class CollegeController {
    @Autowired
    private CollegeService collegeService;
    @GetMapping()
    public Result getAllCollege() {
        Result result = new Result();
        if (StaticUser.permission>=3) {
            return Result.success(collegeService.getAllCollege());
        }
            return Result.fail("权限不足");
    }
    @PostMapping()
    public Result addCollege(@RequestBody College college){
        Result result = new Result();
        if (StaticUser.permission>=4) {
            collegeService.addCollege(college);
            return Result.success("添加成功");
        }
            return Result.fail(ConstStatus.PERMISSION_DISABLED);
    }
}
